Skip to content

Fix potential data-race in EventLoop #3289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2022
Merged

Fix potential data-race in EventLoop #3289

merged 3 commits into from
May 23, 2022

Conversation

qwwdfsad
Copy link
Collaborator

Fixes #3251

@qwwdfsad qwwdfsad requested a review from dkhalanskyjb May 17, 2022 09:51
@@ -410,6 +415,7 @@ internal abstract class EventLoopImplBase: EventLoopImplPlatform(), Delay {
*/
@JvmField var nanoTime: Long
) : Runnable, Comparable<DelayedTask>, DisposableHandle, ThreadSafeHeapNode {
@Volatile
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this volatile, removeAtImpl may see an arbitrary value at assert { result.heap === this }, leading to a potential crash.

Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find any negative consequences of the change of order, looks good.

@dkhalanskyjb dkhalanskyjb self-requested a review May 20, 2022 13:14
@qwwdfsad qwwdfsad merged commit 8cdb4d6 into develop May 23, 2022
@qwwdfsad qwwdfsad deleted the eventloop-race branch May 23, 2022 10:20
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this pull request Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants